#Harris 1973 Confidence in Government Survey, study no. 2343

## packages 
require("dplyr")
require("readstata13")

## set working directory
## to replication folder

## download data
survey <- read.dta13("Harris_Data/Harris 1973 Confidence in Government Survey, study no. 2343/harris_s2343_public_spss.dta")


## pid
survey$pid <- c(1:nrow(survey))
class(survey$pid)

## study number
survey$study <- as.character(2343)
class(survey$study)

## year
survey$year <- 1973
class(survey$year)

## geographpic data
summary(survey$S13)
survey$urban <- as.character(survey$S13)
summary(survey$urban)

## region 
summary(survey$S11)
survey$region <- as.character(survey$S11)

## respondent name
survey$hh <- NA

## inequality increasing
summary(survey$Q8_B)
survey$inequality <- as.character(survey$Q8_B)

## inequality variable version
survey$inequality.variable <- 1
class(survey$inequality.variable)

## union 
survey$union.self <- as.character(survey$F6_1)
survey$union.self[survey$F6_4 == "Yes"] <- "Not Sure"

survey$union.other <- as.character(survey$F6_2)
survey$union.other[survey$F6_4 == "Yes"] <- "Not Sure"

## Are you employed? what kind of employment?
summary(survey$F2A)
survey$employed <- as.character(survey$F2A)
summary(survey$employed)

## employed.self
survey$employed.self <- NA

## Occupation
summary(survey$F2B)
survey$occupation <- as.character(survey$F2B)

## occupation self
survey$occupation.self <- NA

## household size
survey$hhsize <- NA

## Education
summary(survey$F5)
survey$educ <- as.character(survey$F5)

## Income
summary(survey$F7)
survey$income <- as.character(survey$F7)

## Age 
summary(survey$F4)
survey$age <- as.character(survey$F4)

## race
summary(survey$F10)
survey$race <- as.character(survey$F10)

## politics 
summary(survey$Q1D)
survey$party <- as.character(survey$Q1D)

## ideology
survey$ideology <- NA
summary(survey$ideology)

## gender
summary(survey$F11)
survey$gender <- as.character(survey$F11)
table(survey$gender)

## religion
summary(survey$F8)
survey$religion <- as.character(survey$F8)
summary(survey$religion)

## factuals
## do you know the congressman from this district
summary(survey$Q14A)
survey$factual1 <- as.character(survey$Q14A)

## do you know the senator from this state
summary(survey$Q14C)
survey$factual2 <- as.character(survey$Q14C)

## do you know the governor? 
summary(survey$Q14E)
survey$factual3 <- as.character(survey$Q14E)

## alienation index
survey$dontcare <- as.character(survey$Q8_A)
survey$dontcount <- as.character(survey$Q8_D)
survey$leftout <- as.character(survey$Q8_F)

## question_place
survey$question_place <- "after party"


### put together data set
survey_2343 <- survey[,c("pid", "study", "year", "urban", "region", "hh",
                         "inequality", "inequality.variable", "union.self", "union.other",
                         "employed", "employed.self", "occupation", "occupation.self", "hhsize", "educ", "income", 
                         "age", "race", "party", "ideology", "gender", "religion",
                         "factual1", "factual2", "factual3", "dontcare", "dontcount", "leftout",
                         "question_place")]


## save dataset in folder (i.e. working directory must be set to folder)
#saveRDS(survey_2343, file = "Harris_Data/survey_2343.rds")



